unit con_ItemMaquina;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids,
  Mask, ToolEdit,dbtables,db;

type
  TFrmCon_ItemMaquina = class(TFrmConsulta)
    Label8: TLabel;
    EdtData: TDateEdit;
    DBGrid: TDBGrid;
    procedure FormActivate(Sender: TObject);
    procedure EdtDataKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormCreate(Sender: TObject);
    procedure BtnFecharClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    Procedure FazConsulta;
  public
    Num_Planilha: string;
  end;

var
  FrmCon_ItemMaquina: TFrmCon_ItemMaquina;

implementation

uses clsItem_Maquina,Dm;

var Item_Maquina: TItem_Maquina;
    tq          : TQuery;
    tds         : TDataSource;

{$R *.DFM}

procedure TFrmCon_ItemMaquina.FazConsulta;
begin
 Item_Maquina.Consultar(EdtData.Date,tq);
end;

procedure TFrmCon_ItemMaquina.FormActivate(Sender: TObject);
begin
  inherited;
 tq.DatabaseName  := DmInt.Db.DatabaseName;
 tq.Active        := false;
 Tds.DataSet      := tq;
 DBGrid.DataSource:= Tds;
 FazConsulta;
 EdtData.SetFocus;
end;

procedure TFrmCon_ItemMaquina.EdtDataKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
 if key=12 then FazConsulta;
end;

procedure TFrmCon_ItemMaquina.FormCreate(Sender: TObject);
begin
  inherited;
 tq          := TQuery.create(DmInt);
 Tds         := TDataSource.create(DmInt);
 Item_Maquina:= TItem_Maquina.create;
end;

procedure TFrmCon_ItemMaquina.BtnFecharClick(Sender: TObject);
begin
  inherited;
 Num_Planilha:= tq.fieldbyname('Num_Planilha').Asstring;
end;

procedure TFrmCon_ItemMaquina.FormDestroy(Sender: TObject);
begin
  inherited;
 Item_Maquina.free;
 tq.free;
 tds.free;
end;

end.
